import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from "@/views/layout/index.vue";
import home from "@/views/Home.vue";
import admin from "@/views/admin/index";//Admin.vue
import login from "@/views/Login.vue";
import product from "@/views/product/index";
import productinfo from "@/views/productInfo/index";//Product.vue
import productSH from "@/views/productInfoSH/index.vue";
import report from "@/views/report/index";
import reportSH from "@/views/reportSH/index.vue";
import testsSummary from "@/views/testsSummary/index.vue"
import speed from "@/views/speed/index.vue"
import vegetation from "@/views/vegetation/index.vue"
import soilfirmnes from "@/views/soilfirmnes/index.vue"
import temperatureHumidity from "@/views/temperatureHumidity/index.vue"
import deepStability from "@/views/deepstabilityrecord/index.vue";
import usersurvey from "@/views/usersurvey/index.vue";
import productverificare from "@/views/productverificarecord/index.vue";
import experimentrecord from "@/views/experimentrecord/index.vue";
import authenticationtask from "@/views/authenticationtask/index.vue";
import entrepreneur from "@/views/entrepreneur/index";
import instrument from "@/views/instrument/index";
import specification from "@/views/specification/index";
import consistencycheck from "@/views/consistencycheck/index";
import inspresupro from "@/views/inspresupro/index.vue";
import sampletransfer from "@/views/sampletransfer/index.vue";
import conscheckrecord from "@/views/conscheckrecord/index.vue";
import keyinstrument from "@/views/keyinstrument/index.vue";
import breakage from "@/views/breakage/index.vue";

Vue.use(VueRouter)
const adminList = () => import('../views/admin/adminList/admin')
const productList = () => import('../views/product/productList/product.vue')
const productinfoList = () => import('../views/productInfo/productInfoList/productinfo')
const productDetails = () => import('../views/productInfo/productInfoList/productinfo-add-or-update')
const reportList = () => import('../views/report/reportList/report')
const reportAudit = () => import('../views/reportSH/reportList/reportAudit')
const productSHList = () => import('../views/productInfoSH/productInfoList/productinfo')
const productSHAudit = () => import('../views/productInfoSH/productInfoList/ProductInfoAudit.vue')
const reportSHList = () => import('../views/reportSH/reportList/report')
const summaryList = () => import('../views/testsSummary/summaryList/summary.vue')
const speedList = () => import('../views/speed/speedList/speed.vue')
const vegetationList = () => import('../views/vegetation/vegetationList/vegetation.vue')
const soilfirmnesList = () => import('../views/soilfirmnes/soilfirmnesList/soilfirmnes.vue')
const humidityList = () => import('../views/temperatureHumidity/temperatureHumidityList/humidity.vue')
const deepStabilityList = () => import('../views/deepstabilityrecord/deepstabilityrecordList/deepstabilityrecord.vue')
const usersurveyList = () => import('../views/usersurvey/usersurveyList/usersurveysummary.vue')
const productverificareList = () => import('../views/productverificarecord/productverificarecordList/productverificarecord.vue')
const experimentrecordList = () => import('../views/experimentrecord/experimentrecordList/experimenttalinvestigationrecord.vue')
const instrumentList = () => import('../views/instrument/instrumentList/instrument')
const entrepreneurList = () => import('../views/entrepreneur/entrepreneurList/entrepreneur')
const authenticationtaskList = () => import('../views/authenticationtask/authenticationtaskList/authenticationtask')
const specificationList = () => import('../views/specification/specificationList/productspecification')
const consistencycheckList = () => import('../views/consistencycheck/consistencycheckList/consistencycheck')
const inspresuproList = () => import('../views/inspresupro/inspresuproList/inspresupro')
const sampletransferList = () => import('../views/sampletransfer/sampletransferList/sampletransfer')
const conscheckrecordList = () => import('../views/conscheckrecord/conscheckrecordList/conscheckrecord')
const keyinstrumentList = () => import('../views/keyinstrument/keyinstrumentList/keyinstrument')
const breakageList = () => import('../views/breakage/breakageList/breakagerate')


const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/index',
        component: layout,
        children: [
            {
                path: '/',
                name: home,
                component: home,
            },
            {
                path: '/admin',
                name: admin,
                component: admin,
                children: [{
                    path: 'admin-list',
                    component: adminList
                }]
            }, {
                path: '/productinfo',
                name: 'productinfo',
                component: productinfo,
                children: [{
                        path: '/productinfo-list',
                        component: productinfoList
                    }, {
                        path: '/productinfo-add-or-update',
                        component: productDetails
                    }
                ]
            }, {
                path: '/report',
                name: 'report',
                component: report,
                children: [{
                    path: '/report-list',
                    component: reportList
                }, {
                    path: '/report-audit',
                    name: 'report-audit',
                    component: reportAudit
                }]
            }, {
                path: '/productSH',
                name: 'productSH',
                component: productSH,
                children: [{
                    path: '/productSH-list',
                    component: productSHList
                }, {
                    path: '/productSH-audit',
                    name: 'productSH-audit',
                    component: productSHAudit
                }]
            }, {
                path: '/reportSH',
                name: 'reportSH',
                component: reportSH,
                children: [{
                    path: '/reportSH-list',
                    component: reportSHList
                }]
            },{
                path:'/summary',
                name:'summary',
                component: testsSummary,
                children:[{
                    path:"/summary-list",
                    component: summaryList
                }]
            },{
                path: '/summary-list-audit',
                name: 'summary-list-audit',
                component: () => import('@/views/testsSummary/audit-list.vue')
            },
            {
                path:'/speed',
                name:'speed',
                component: speed,
                children:[{
                    path:"/speed-list",
                    component: speedList
                }]
            },{
                path: '/speed-list-audit',
                name: 'speed-list-audit',
                component: () => import('@/views/speed/audit-list.vue')
            },{
                path:'/vegetation',
                name:'vegetation',
                component: vegetation,
                children:[{
                    path:"/vegetation-list",
                    component: vegetationList
                }]

            },{
                path: '/vegetation-list-audit',
                name: 'vegetation-list-audit',
                component: () => import('@/views/vegetation/audit-list.vue')
            },{
                path:'/soilfirmnes',
                name:'soilfirmnes',
                component: soilfirmnes,
                children:[{
                    path:"/soilfirmnes-list",
                    component: soilfirmnesList
                }]
            },{
                path: '/firmness-list-audit',
                name: 'firmness-list-audit',
                component: () => import('@/views/soilfirmnes/audit-list.vue')
            },{
                path:'/temperatureHumidity',
                name:'temperatureHumidity',
                component: temperatureHumidity,
                children:[{
                    path:"/humidity-list",
                    component: humidityList
                }]
            },{
                path: '/temperature-list-audit',
                name: 'temperature-list-audit',
                component: () => import('@/views/temperatureHumidity/audit-list.vue')
            },{
                path: '/deepStability',
                name: 'deepStability',
                component: deepStability,
                children: [{
                    path: '/deepstabilityrecord-list',
                    component: deepStabilityList
                }]
            },{
                path: '/usersurvey',
                name: 'usersurvey',
                component: usersurvey,
                children: [{
                    path: '/usersurvey-list',
                    component: usersurveyList
                }]
            },
            {
                path: '/productverificare',
                name: 'productverificare',
                component: productverificare,
                children: [{
                    path: '/productverificare-list',
                    component: productverificareList
                }]
            },
            {
                path: '/conscheckrecord',
                name: 'conscheckrecord',
                component: conscheckrecord,
                children: [{
                    path: '/conscheckrecord-list',
                    component: conscheckrecordList
                }]
            },{
                path: '/cons_check-list-audit',
                name: 'cons_check-list-audit',
                component: () => import('@/views/conscheckrecord/audit-list.vue')
            },{
                path: '/keyinstrument',
                name: 'keyinstrument',
                component: keyinstrument,
                children: [{
                    path: '/keyinstrument-list',
                    component: keyinstrumentList
                }]
            },
            {
                path: '/instrument-list-audit',
                name: 'instrument-list-audit',
                component: () => import('@/views/keyinstrument/audit-list.vue')
            },
            {
                path: '/experimentrecord',
                name: 'experimentrecord',
                component: experimentrecord,
                children: [{
                    path: '/experimentrecord-list',
                    component: experimentrecordList
                }]
            }
            ,{
                path: '/authenticationtask',
                name: 'authenticationtask',
                component: authenticationtask,
                children: [{
                    path: '/authenticationtask-list',
                    component: authenticationtaskList
                }]
            },{
                path: '/authenticationtask-list-audit',
                name: 'authenticationtask-list-audit',
                component: () => import('@/views/authenticationtask/audit-list.vue')
            },{
                path: '/product',
                name: 'product',
                component: product,
                children: [{
                    path: '/product-list',
                    component: productList
                }]
            },{
                path: '/entrepreneur',
                name: 'entrepreneur',
                component: entrepreneur,
                children: [{
                    path: '/entrepreneur-list',
                    component: entrepreneurList
                }]
            },{
                path: '/instrument',
                name: 'instrument',
                component: instrument,
                children: [{
                    path: '/instrument-list',
                    component: instrumentList
                }]
            },{
                path: '/specification',
                name: 'specification',
                component: specification,
                children: [{
                    path: '/specification-list',
                    component: specificationList
                }],
            },{
                path: '/inspresupro',
                name: 'inspresupro',
                component: inspresupro,
                children: [{
                    path: '/inspresupro-list',
                    component: inspresuproList
                }],
            },{
                path: '/sampletransfer',
                name: 'sampletransfer',
                component: sampletransfer,
                children: [{
                    path: '/sampletransfer-list',
                    component: sampletransferList
                }],
            },
            {
                path: '/sampleSheet',
                name: 'sampleSheet',
                component: () => import('@/views/sampleSheet/list'),
            },
            {
                path: '/sampleInspection',
                name: 'sampleInspection',
                component: () => import('@/views/sampleInspection/list'),
            },
            {
                path: '/sampleSheetAudit',
                name: 'sampleSheetAudit',
                component: () => import('@/views/sampleSheet/audit-list'),
            },
            {
                path: '/sampleInspectionAudit',
                name: 'sampleInspection',
                component: () => import('@/views/sampleInspection/audit-list'),
            },
            {
                path: '/safetyAssessment',
                name: 'safetyAssessment',
                component: () => import('@/views/safetyAssessment/list'),
            },
            {
                path: '/safetyAssessmentAudit',
                name: 'safetyAssessmentAudit',
                component: () => import('@/views/safetyAssessment/audit-list'),
            },
            {
                path: '/handoverChecklist',
                name: 'handoverChecklist',
                component: () => import('@/views/handoverChecklist/list'),
            },
            {
                path: '/handoverChecklistAudit',
                name: 'handoverChecklist',
                component: () => import('@/views/handoverChecklist/audit-list'),
            },
            {
                path: '/usersurvery-list-audit',
                name: 'usersurvery-list-audit',
                component: () => import('@/views/usersurvey/audit-list'),
            },
            {
                path: '/consistencycheck',
                name: 'consistencycheck',
                component: consistencycheck,
                children: [{
                    path: '/consistencycheck-list',
                    component: consistencycheckList
                }]
            },{
                path:'/breakage',
                name:'breakage',
                component: breakage,
                children:[{
                    path:"/breakage-list",
                    component: breakageList
                }]
            },
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: login
    }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if(to.meta.title)  document.title = to.meta.title
  // if(to.path === '/login') return next()
  // if(!sessionStorage.getItem('token')) return next('/login')
  next()
})

export default router
